package proxy;

import org.apache.commons.logging.Log;

/**
 * demo 1 静态代理
 */
class TimeProxy implements Move{
    private Move m;
    TimeProxy(Move m){
        this.m = m;
    }

    @Override
    public void move() {
        long start = System.currentTimeMillis();
        m.move();
        long end = System.currentTimeMillis();

        System.out.println(end - start);
    }
}

class LogProxy implements Move{
    private Move m;
    LogProxy(Move m){
        this.m = m;
    }

    @Override
    public void move() {
        System.out.println("log");
        m.move();
    }
}

/**
 * 静态代理
 */
public class SimpleProxy {
    public static void main(String[] args) {
        System.out.println("SimpleProxy");

        // demo 使用聚合代理套代理
        Move m = new TimeProxy(new LogProxy(new Tank()));
        m.move();
    }
}
